home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: swampwiz@ix.netcom.com(Jean P. Laborde )
- Newsgroups: comp.lang.c++
- Subject: Re: How to delete array of pointers?
- Date: 10 Feb 1996 14:07:41 GMT
- Organization: Netcom
- Message-ID: <4fi8rd$738@reader2.ix.netcom.com>
- References: <4fgvsu$5q4@eng_ser1.erg.cuhk.hk>
- NNTP-Posting-Host: ix-no1-15.ix.netcom.com
- X-NETCOM-Date: Sat Feb 10 6:07:41 AM PST 1996
-
- In <4fgvsu$5q4@eng_ser1.erg.cuhk.hk> ywleung@cs.cuhk.hk (Marty McFly)
- writes:
- >
- >If I write the following code in a function:
- >
- > int** ptr;
- > ptr = new int*[1000];
- >
- >Is this code means allocating 1000 integer pointers which is pointed
- by ptr?
- >And then somehow I assign integer variable to ptr[0], ptr[1], ... and
- so on.
- >So at the end of the function, how can I reclaim just those pointers?
- The key
- >point is that those integer variable assigned to the pointers should
- not be
- >deleted.
- >
- >Regards,
- >Marty McFly.
-
- how about:
-
- for(int i=0;i<1000;i++)
- delete ptr[i];
- delete ptr;
-
-
-